﻿using System.IO.IsolatedStorage;
using System.Windows.Browser;
using System.Windows.Controls;
using Lib.Helper;
using CashBankIn.ViewModels;
using WcfService1.DTO;

namespace CashBankIn
{
    public partial class Index : Page
    {
        public Index()
        {
            InitializeComponent();
            CashBankInViewModel.OnSearchCompleted = (x) => { DataContext = x; };

            EventAggregator.RegisterMessage("SearchCashBankIn", (o, e) =>
                                                                {
                                                                    var search = new Search();
                                                                    search.Show();
                                                                });
           
        }

        private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            var si = (sender as Button).DataContext as CashBankInDTO;
            IsolatedStorageSettings UserSettings = IsolatedStorageSettings.ApplicationSettings;
            MyButton button = new MyButton(UserSettings["url"].ToString() + "CashIn.aspx?no=" + HttpUtility.UrlEncode(si.NoVoucher));
            button.ClickMe();
        }
    }
}